<template>
  <div class="bottom-nav">
    <div
      class="item"
      :class="{active: active == 'home'}"
      @click="active == 'home' ? null : $router.push('/')"
    >
      <img
        src="@/components/BottomNav/icon/home_a.png"
        v-if="active == 'home'"
      >
      <img
        src="@/components/BottomNav/icon/home.png"
        v-else
      >
      首页
    </div>
    <div
      class="item"
      :class="{active: active == 'my'}"
      @click="active == 'my' ? null : $router.push('/my')"
    >
      <img
        src="@/components/BottomNav/icon/my_a.png"
        v-if="active == 'my'"
      >
      <img
        src="@/components/BottomNav/icon/my.png"
        v-else
      >
      我的
    </div>
    <div
      class="scan"
      @click="$router.push('/scan')"
    >
      <img src="@/components/BottomNav/icon/scan.png">
      扫码
    </div>
  </div>
</template>

<script>
export default {
  name: "BottomNav",
  props: {
    active: {
      type: String,
      default: "home"
    }
  },
  data() {
    return {};
  },
};
</script>

<style lang="scss" scoped>
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 49px;
  background: #ffffff;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  box-shadow: 0px -1px 4px rgba(0, 0, 0, 0.1);
  .item {
    width: 152px;
    height: 49px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    color: #666666;
    &.active {
      color: #3798fb;
    }
    img {
      width: 24px;
      height: 24px;
      margin-bottom: 3px;
    }
  }
  .scan {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -14px;
    font-size: 10px;
    color: #666666;
    width: 43px;
    text-align: center;
    line-height: 1;
    img {
        width: 43px;
        height: 43px;
        margin-bottom: 5px;
    }
  }
}
</style>
